<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <title>注册</title>
  <link rel="stylesheet" href="/css/common.css">
  <link rel="stylesheet" href="/css/register.css">
  <link rel="stylesheet" href="/css/personal_center.css">
  <script src="/js/jquery.js"></script>

  <script>
    jQuery(document).ready(function(){

        jQuery("#get_vcode").on("click", function(event) {
	        event.preventDefault();
	        jQuery.ajax({
		        scriptCharset: 'utf-8',
		        type: "POST",
                url: "/verification",
                contentType: "application/json",
                data: JSON.stringify({
                    "phonenumber":  jQuery("#phonenumber_id").val()
                }),
                dataType: "json",
                success: function(result) {
                },
                error: function(result) {
                }
            });

            var time=60;
            jQuery("#get_vcode").attr("disabled",true);
            var t = setInterval(function(){
                if(time == 0){
                    clearInterval(t);
                    jQuery("#get_vcode").attr("disabled",false);
                    jQuery("#get_vcode").html("获取验证码");
                }
                else{
                    time--;
                    jQuery("#get_vcode").html(time+"秒后重发");
                }
                
            }, 1000)

        });

        jQuery("#input_vcode_id").on("mouseout", function(event){
            event.preventDefault();
            //alert("MOUSEout works");
            var input_text = jQuery(event.target).val()
            if (input_text == null || input_text == undefined || input_text == ""){
                //alert("判断验证码是否为空");
                jQuery(".tips_cls").text("验证码不能为空");
                return;
            }
        });

        //When typing the v-code, no error message
        jQuery("#input_vcode_id").on("mouseenter", function(event){
            event.preventDefault();
            jQuery(".tips_cls").text("");
            return;
        });
        //When ..., no error message
        jQuery("#get_vcode").on("mouseenter", function(event){
            event.preventDefault();
            jQuery(".tips_cls").text("");
            return;
        });
        //When ..., no error message
        jQuery("#phonenumber_id").on("mouseenter", function(event){
            event.preventDefault();
            jQuery(".tips_cls").text("");
            return;
        });
        //When ..., no error message
        jQuery("#user_id").on("mouseenter", function(event){
            event.preventDefault();
            jQuery(".tips_cls").text("");
            return;
        });
        //When ..., no error message
        jQuery("#pw_id").on("mouseenter", function(event){
            event.preventDefault();
            jQuery(".tips_cls").text("");
            return;
        });
        //When ..., no error message
        jQuery("#pw2_id").on("mouseenter", function(event){
            event.preventDefault();
            jQuery(".tips_cls").text("");
            return;
        });


        jQuery("#register").on("click", function(event) {
	        event.preventDefault();
	        jQuery.ajax({
		        scriptCharset: 'utf-8',
		        type: "POST",
                url: "/register",
                contentType: "application/json",
                data: JSON.stringify({
                    "phonenumber":  jQuery("#phonenumber_id").val(),
                    "username":  jQuery("#user_id").val(),
                    "password":  jQuery("#pw_id").val(),
                    "password2":  jQuery("#pw2_id").val(),
                    "input_vcode":  jQuery("#input_vcode_id").val()
                }),
                dataType: "json",
                success: function(result) {
                    //alert(result.errormessage);
                    if(result.errorcode == 1){
                        //alert("Got to login.");
                        window.location.href="/login";
                    }
                    if(result.errorcode == 2){
                      jQuery(".tips_pw2_cls").text("两次输入密码不一致，请重试");
                    }
                    if(result.errorcode == 3){
                      alert(result.errormessage);
                      jQuery(".tips_cls").text("验证码有误，请重试");
                    }
                    else{
                        //alert("EXIST num.");
                        jQuery(".tips_phonenumber_cls").text("此电话号码已注册，请重试");
                    }

                },
                error: function(result) {
                    //alert(result);
                }
            });
        });
        
        jQuery("#phonenumber_id").on("mouseout", function(event){
            event.preventDefault();
            //alert("MOUSEout phonenumber works");
            var input_text = jQuery(event.target).val()
            //if (input_text == null || input_text == undefined || input_text == ""){
            //    alert("判断手机码是否为空");
            //    jQuery(".tips_phonenumber_cls").text("手机号码不能为空");
            //    return;
            //}
            if(input_text.length !=11){
                jQuery(".tips_phonenumber_cls").text("请输入正确的手机号码");
                return;
            }
            else{
                jQuery(".tips_phonenumber_cls").text("");
                return; 
            }
        });

        jQuery("#pw_id").on("mouseout", function(event){
            event.preventDefault();
            //alert("MOUSEout phonenumber works");
            var input_text = jQuery(event.target).val()
            //if (input_text == null || input_text == undefined || input_text == ""){
            //    alert("判断密码是否为空");
            //    jQuery(".tips_pw_cls").text("密码不能为空");
            //    return;
            //}
            if(input_text.length <6 ||input_text.length >20 ){
                jQuery(".tips_pw_cls").text("请输6-20位密码");
                return;
            }
            else{
                jQuery(".tips_pw_cls").text("");
                return;
            }
        });
        jQuery("#pw2_id").on("mouseout", function(event){
            event.preventDefault();
            //alert("MOUSEout phonenumber works");
            var input_text = jQuery(event.target).val()
            var input2_text = jQuery(this).prev("#pw_id");
            if(input_text != input2_text){
                jQuery(".tips_pw2_cls").text("两次输入的密码不一致");
                return;
            }
            else{
                jQuery(".tips_pw2_cls").text("");
                return;
            }
        });
    });
  </script>

</head>
<body>
  <header class="header">
    <div class="column">
      <img class="logo" src="http://our8pafcg.bkt.clouddn.com/zhike/images/logo.png" alt="智客">
      <div class="title-group">
        欢迎注册
      </div>
    </div>
  </header>
  <div class="container">
    <div class="form-wrapper">
      <div class="title-wrapper">
        <h3>用户注册</h3>
        <div class="to-login-wrapper">
          <span>已有账号,</span>
          <a href="/login">立即登录&gt;</a>
        </div>
      </div>
      <form method="post" class="default_form" action="/register">
      <input type="text" id="phonenumber_id" placeholder="请输入手机号码" name=phonenumber>
        <span class="tips_phonenumber_cls" style="color:red;font-size:10px"></span><br>
      <input type="text" id="user_id" placeholder="请输入用户名" name=username><br>
      <input type="password" id="pw_id" placeholder="请输入密码(6-20位，可包含数字字母特殊字符)" name=password >
        <span class="tips_pw_cls" style="color:red;font-size:10px"></span><br>
      <input type="password" id="pw2_id" placeholder="请再次输入密码" name=password2>
        <span class="tips_pw2_cls" style="color:red;font-size:10px"></span><br>
      <div class="code-wrapper">
        <input type="text" id="input_vcode_id" placeholder="请输入验证码" name=vcode > </input>
        <button class="btn btn-primary btn-code" id='get_vcode' type='push'>获取验证码 </button>
      </div>
      <button class="btn btn-primary btn-block" id='register'>立即注册</button>
        <span class="tips_cls" style="color:red;font-size:10px"></span>
      <div class="service-protocol">
        <input type="checkbox" checked="checked" >我已阅读并同意<a href="#">服务协议</a>和<a href="#">隐私政策</a>
      </div>
      </form>


    </div>
  </div>

  <footer class="footer">
    <div class="inner-wrap">
      <div>
        <p class="col-title"><i class="iconfont icon-link"></i>&nbsp;相关链接</p>
        <div class="content">
          <a href="http://www.datayes.com/" target="_blank">通联数据</a>&nbsp;&nbsp;让投资更容易
          <br/>
          <a href="http://m.datayes.com/" target="_blank">数据商城</a>&nbsp;&nbsp;海量金融大数据
          <br/>
          <a href="https://mof.datayes.com/" target="_blank">通联魔方</a>&nbsp;&nbsp;MOM/FOF全流程管理平台
          <br/>
          <a href="https://robo.tt/home/" target="_blank">萝卜投研</a>&nbsp;&nbsp;智能投研平台
          <br/>
          <a href="http://www.jinlingxuetang.com" target="_blank">金领学堂</a>&nbsp;&nbsp;学习更便捷
        </div>
      </div>
      <div>
        <p class="col-title"><i class="iconfont icon-location"></i>&nbsp;联系地址</p>
        <div class="content">
          总部地址： 北京市朝阳区望京街道保利国际广场T2-303
          <br/>成都分部： 四川省成都市天府大道中段希顿广场C座701
        </div>
      </div>
      <div>
        <p class="col-title"><i class="iconfont icon-telephone"></i>&nbsp;联系方式</p>
        <div class="content">
          电话: 400-696-8026
        </div>
      </div>
      <div class="qrcode-wrapper">
        <img class="qrcodeimg" src="https://uqer.io/home/img/code.jpg" alt="二维码"><br>
        <span>扫描二维码关注公众号</span>
      </div>
    </div>
    <br>
    <p class="copyright">
      <span>© 2017 <a href="http://www.datayes.com/" target="_blank">DataYes</a></span>
      <a class="icp" href="http://www.miibeian.gov.cn/" target="_blank">沪ICP备13045831号</a>
      <span>咨询热线：4000 820 386</span>
      <span>智客 Beta</span>
      <a href="http://www.datayes.com/protocol" target="_blank">用户协议</a>
    </p>
  </footer>
</body>
</html>
